<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <c:set var="ctx" value="${pageContext.request.contextPath }"></c:set>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
		<title>华阳物流</title>
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/bootstrap.min.css"/>	
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/public.css"/>
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/font-awesome.4.6.0.css"/>
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/combo.select.css">
		<link href="<%=request.getContextPath()%>/resources/css/foundation.min.css" rel="stylesheet" type="text/css">
		<link href="<%=request.getContextPath()%>/resources/css/foundation-datepicker.css" rel="stylesheet" type="text/css">
		<script src="<%=request.getContextPath()%>/resources/js/jquery-1.7.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="<%=request.getContextPath()%>/resources/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="<%=request.getContextPath()%>/resources/js/foundation-datepicker.js" type="text/javascript" charset="utf-8"></script>		
		<script src="<%=request.getContextPath()%>/resources/js/jquery.combo.select.js" type="text/javascript" charset="utf-8"></script>		
	</head>
	<body class="huayang">
		<header class="clearfix">
			<a class="navbar-brand d-inline logo2" href="#"><img src="<%=request.getContextPath()%>/resources/img/logo.png"></a>
			<a class="navbar-brand d-inline logo3" href="#"><img src="<%=request.getContextPath()%>/resources/img/1.png"></a>
		</header>
		<div class="clearfix">
			
		</div>
		<input type="hidden" id="deptid" value="${deptid }">
        <nav class="navbar navbar-expand-lg navbar-light bg-light">
            <!--<a class="navbar-brand" href="#">Navbar</a>-->
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
              <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse" id="navbarSupportedContent">
           	
              <ul class="navbar-nav mr-auto">
              	<div class="container">       	
            	<div class="row clearfix">
              	<li id="cheng" class="nav-item active col-xs-6">
                  <a class="nav-link nav1" href="${ctx }/department/chengCity?deptid=${deptid}&&rolename=${role.rolename}"><span></span></a>
                </li>
                <li id="mian" class="nav-item active col-xs-6">
                  <a class="nav-link nav2" href="${ctx }/department/mianCity?deptid=${deptid}&&rolename=${role.rolename}"><span></span></a>
                </li>
                 <li id="mz" class="nav-item active col-xs-6">
                  <a class="nav-link nav6" href="${ctx }/department/mzCity?deptid=${deptid}&&rolename=${role.rolename}"><span></span></a>
                </li>
                <li class="nav-item active col-xs-6">
                  <a class="nav-link nav3" href="${ctx }/after/showAfter?pageNow=1&&deptid=${deptid}&&rolename=${role.rolename}"><span></span></a>
                </li>
                <li class="nav-item active col-xs-6">
                 <a class="nav-link nav4" href="${ctx }/accountlist/selectAccountList?deptid=${deptid}&&rolename=${role.rolename}&deptname=&zhiling=&chexing=&xingming=&jiesuan=&jiashiyuanjs=&fatime1=&fatime2="><span></span></a>
                </li>
                <li class="nav-item active col-xs-6">
                  <a class="nav-link nav5" href="${ctx }/back/guanli?deptid=${deptid}&&rolename=${role.rolename}"><span></span></a>
                </li>
               </div>
              </div>
              </ul>
            <div class="clearfix"></div>
            <ul class="nav justify-content-center fixed-top align-middle clearfix ">
			  <li class="nav-item">
                <img class="user-img rounded-circle" src="<%=request.getContextPath()%>/resources/img/raw_1514434504.jpg"/>  
              </li>
              <li class="nav-item user-info">
                <span>${user.uname}</span>    
                <span>${role.rolename}</span> <input type="hidden" id="rolename" value="${role.rolename}">
              </li>
              <li class="nav-item pwd-change">
                <a class="nav-link active align-text-bottom" href="${ctx }/tuser/pwdjsp?deptid=${deptid}">修改密码</a>                
              </li>
              <li class="nav-item exit"> 
              	<a href="${ctx }/back/userLoginOut" onclick="return confirm('您确定要退出系统吗？');" class="nav-link active"><span class="px-3">
					<img src="<%=request.getContextPath()%>/resources/img/exit.png"></span>退出</a>     
              </li>
            </ul>
          </div>       
        </nav>	
        <div class="container-fluid content">
        	<div class="row">
        		<div class="page_position d-none d-sm-block">
        			<!--位置-->
        			<!--<div class="container-fluid pl-5">
        				<div class="row py-3">
        					<a href="#">成都</a>>>
        				</div>
        			</div>-->
        		</div>
        		
        			<div class="container-fluid  py-5 p-0">
        				<div class="row pt-xl-4 col-10">
        				   <div class="container" id="contet-box">
        				   	<!--运单登记-->
        				   	<div class="row clearfix px-5">
		                    <div class="container_form ">
			                <form action="${ctx }/waybills/addWaybill?deptid=${deptid}&&rolename=${role.rolename}" method="post" onsubmit="return yuntest()" id="fileupload" enctype="multipart/form-data" role="form" > 
		                	<input type="hidden" id="deptid" name="deptid" value="${deptid }">
		                	<input type="hidden" id="nameId" name="nameId" value="${user.uid}">
			                	<div class="col-md-6 form-group input-group-one float-left">
			                	<p class="text-left">基本信息</p>
				                <div class="form-group col-md-12 column col-center-block">
							        <div class="input-group">
								        <div class="input-group-addon">始发地：</div>
								        <!-- <select name="wcommence" id="wcommence"  onchange="catalogABC();" class="form-control"> -->
								        <select name="wcommence" id="wcommence"  onchange="catalogABC();" class="form-control">
                                            <option >--请选择--</option>
	                                   		  <c:forEach items="${requestScope.carsShiFasRe}" var="keyword" varStatus="id">  
     												    	<option      value="${keyword}"   class="form-control">${keyword}</option> 
   											  </c:forEach>  
                                            
                                        </select>
							        </div>
							        <div class="input-group">
								        <div class="input-group-addon">目的地：</div>
                                        <select name="wbourn" id="wbourn"    onchange="secondQuery();"  class="form-control">
                                            <option selected="selected">--请选择--</option>
                                        </select>
							        </div>	
							        <div class="input-group">
								        <div class="input-group-addon">车架号：</div>
                                        <input type="text"  name="wvehicle" id="wvehicle" onclick="checkWbourn();"  class="form-control" >
							        </div>
							        <div class="input-group">
								        <div class="input-group-addon">车型：</div>
                                        <select    name="wvin" id="wvin"   onchange="thirdQuery();" onclick="checkWbourn();"    class="form-control">
                                            <option selected="selected">--请选择--</option>
                                        </select>
							        </div>
							        <div class="input-group">
								        <div class="input-group-addon">驱数：</div>
                                        <select name="wactuate"       onchange="fourthQuery();" onclick="checkWbourn();" id="wactuate" class="form-control">
                                            <option selected="selected">--请选择--</option>
                                        </select>
							        </div>
						        </div>	
			                	</div>
			                	
						        <div class="col-md-6 form-group input-group-one float-right">
						        <p class="text-left">时间信息</p>
				                <div class="form-group col-md-12 column col-center-block clearfix">
							        <div class="input-group">
								        <div class="input-group-addon">发车时间：</div>
								        <input type="text" name="wdeparturetime1" id="wdeparturetime" class="form-control timepick">
							        </div>
							        <div class="input-group">
								        <div class="input-group-addon">预计到达时间：</div>
                                        <input type="text" name="westimatedtime1" id="westimatedtime" class="form-control timepick">
							        </div>	
							        <div class="input-group">
								        <div class="input-group-addon">临牌到达时间：</div>
                                        <input type="text" name="wneartime1" id="wneartime"  class="form-control timepick">
							        </div>
							        <div class="input-group">
								        <div class="input-group-addon">保险到达时间：</div>
                                        <input type="text" name="winsurancetime1" id="winsurancetime" class="form-control timepick">
							        </div>
						        </div>	
						      
						        </div>
						        <div class="clearfix"></div>
						        <div class="form-group input-group-two clearfix">
						        	
				                <div class="form-group col-md-6 column col-center-block float-left">
				                	<p class="text-left">基本信息</p>
				                	<div class="input-group">
								        <div class="input-group-addon">运送驾驶员：</div>
								         <select name="wtransport" id="wtransport"  class="form-control">
                                            <option >--请选择--</option>
	                                   		  <c:forEach items="${ds}" var="dr" >  
     												     <option value="${dr.dname}" class="form-control">${dr.dname}</option> 
   											  </c:forEach>  
                                        </select>
							        </div>
							        <div id="changjia" class="input-group">
								        <div class="input-group-addon">厂家结算：</div>
								        <select name="wfactory" id="wfactory"  onchange="fifthQuery();"   class="form-control">
                                            <option selected="selected"><!-- --请选择-- --></option>
                                        </select>
							        </div>
							        <div class="input-group">
								        <div class="input-group-addon">驾驶员结算：</div>
								          <select name="wpilot" id="wpilot"  class="form-control">
                                            <option selected="selected"><!-- --请选择-- --></option>
                                        </select>
							        </div>
							        
							        <div class="input-group">
								        <div class="input-group-addon">商业险金额：</div>
								        <input type="text" name="wcommercial" id="wcommercial" onkeyup="IWS_CheckDecimal(this)" class="form-control">
							        </div>
							      
						        </div>
						        <div class="form-group col-md-6 column col-center-block float-right">			                	
							        <p class="text-left">基本信息</p>
							        <div class="input-group">
								        <div class="input-group-addon">强险金额：</div>
								        <input type="text" name="wcoerce" id="wcoerce" onkeyup="QIANG_CheckDecimal(this)" class="form-control">
							        </div>
							        <div class="input-group">
								        <div class="input-group-addon">临牌金额：</div>
								        <input type="text" name="wamount" id="wamount" onkeyup="LIN_CheckDecimal(this)" class="form-control">
							        </div>
							        <div class="input-group">
								        <div class="input-group-addon">备注信息：</div>
								        <textarea name="wremark" class="form-control" rows="1"></textarea>
							        </div>
							       
						        </div>
						        

						        </div>
						        
						       <div class="clearfix">
						       	
						       </div>
						        <div class="column col-center-block">
						        	
						        
				                <div class="form-group detail-button" style="padding-bottom: 90px;">
					                <div class="float-left">
						               <button type="submit" class="btn btn-default">提交</button>
						            </div>
                                    <div class="float-right">
                                       <button type="button" class="btn btn-default" onClick="history.back()">取消</button>
                                    </div>
				                </div>
				                </div>
			                </form>
		                </div>          
		            </div>
        				   	<!--运单登记-->
        					</div>
        				</div>       				
        			</div>
        		</div>
        	</div> 
        	<!--推送消息-->
        	
    <jsp:include page="munetab.jsp" />
	</body>
	<script type="text/javascript">
		function checkWbourn(){
			var mudidi = $("#wbourn option:selected").text().trim();   
		    if(mudidi=="--请选择--"){
		     alert("请选择正确的目的地");
		     $("#wbourn").comboSelect();
		    }
		}
	</script>
	<script type="text/javascript">
		$(document).ready(function(){ 
				  var deptid = document.getElementById("deptid").value;
					if(deptid==1){
						$("#cheng").addClass("current"); 
					 
					}
					if(deptid==2){
						
					   $("#mian").addClass("current"); 
					 
					}
					if(deptid==4){
						
					   $("#mz").addClass("current"); 
					 
					}
			}); 
	</script>
	<script type="text/javascript">
			function IWS_CheckDecimal(wcommercial) {
			    var temp = /^\d+\.?\d{0,2}$/;
			    var wcommercial = document.getElementById("wcommercial").value;
			    if (!temp.test(wcommercial)) {
			    	alert("请输入商业险正确金额!");
			    	return false;
			    }
			    
			}
			
			function QIANG_CheckDecimal(wcoerce){
			var wcoerce = document.getElementById("wcoerce").value;
				if (!/^\d+\.?\d{0,2}$/.test(wcoerce)) {
			    	alert("请输入强险正确金额!");
			    	return false;
			    }
			}
			
			function LIN_CheckDecimal(wamount){
			var wamount = document.getElementById("wamount").value;
				if (!/^\d+\.?\d{0,2}$/.test(wamount)) {
			    	alert("请输入临牌正确金额!");
			    	return false;
			    }
			}
	
	
		$(function(){
         	var rolename = $("#rolename").val();
			if(rolename == "业务员"){
				$("#changjia").hide();//隐藏
			}
			if(rolename != "业务员"){
				$("#changjia").show();//显示
			}
         
         });
		
	</script>
	
	<script type="text/javascript">
function catalogABC(){  
    var object = $("#wcommence").val();
    $("#wbourn").empty();
    if(object !=null){
         $.ajax({
                url : '<%=basePath%>cars/getDestinationByDeparture?object='+object,
                type : 'post',
                dataType : 'json',
                async : false,
                //contentType: "application/json; charset=utf-8",
                success : function(data) {
                    console.log(data);                  
                       if(data!=null){
                         	$("#wbourn").prepend("<option value='0'>--请选择--</option>");
                            $.each(data,function(i,item){
                                  $.each(item,function(j,val){
                                      $("#wbourn").append("<option value="+val.cbourn+">"+val.cbourn+"</option>");                                     
                                  })
                                  $("#wbourn").comboSelect();

                              }); 
                       }                                                    
                }

         })
    }else{
        alert("请选择出发地！！");
    }


}


function secondQuery(){
    var mudidi = $("#wbourn option:selected").text().trim();   
     var shifa = $("#wcommence option:selected").text().trim();
    $("#wvin").empty();
    if(mudidi=="--请选择--"){
     alert("请选择正确的目的地");
     $("#wbourn").comboSelect();
    }else{
	     $.ajax({
	             url : '<%=basePath%>cars/getChexingnByDeparture',
	             data:{
	             	mudidiobject: mudidi,
	             	shifaobject: shifa,
	             },
	            type : 'post',
	            dataType : 'json',
	            async : false,          
	            success : function(data) {
	                console.log(data);  
	                   if(data!=null){
	                       $("#wvin").prepend("<option id='wvin' value='0'>--请选择--</option>");
	                        $.each(data,function(i,item){
	                              $.each(item,function(j,val){
	                                  $("#wvin").append("<option value="+val.cmileage+">"+val.cmileage+"</option>");
	                              })
	
	                          }); 
	                   }                                                    
	            }
	     })
    }
}

function thirdQuery(){
    $("#wactuate").empty();
     	 var mudidi = $("#wbourn option:selected").text().trim();   
   	 	 var shifa = $("#wcommence option:selected").text().trim();
    	 var chexing = $("#wvin option:selected").text().trim(); 
     $.ajax({
           url : '<%=basePath%>cars/getQushuByDeparture',
            data:{
             	mudidiobject: mudidi,
             	shifaobject: shifa,
             	chexingobject: chexing,
             },
            type : 'post',
            dataType : 'json',
            async : false,          
            success : function(data) {
                console.log(data);  
                   if(data!=null){
                       $("#wactuate").prepend("<option id='wactuate' value='0'>请选择</option>");
                        $.each(data,function(i,item){
                              $.each(item,function(j,val){
                                  $("#wactuate").append("<option value="+val.cactuate+">"+val.cactuate+"</option>");
                              })
                          }); 
                   }                                                    
            }
     })
}



function fourthQuery(){
    $("#wfactory").empty();
     $("#wpilot").empty();
     	 var mudidi = $("#wbourn option:selected").text().trim();   
   	 	 var shifa = $("#wcommence option:selected").text().trim();
    	 var chexing = $("#wvin option:selected").text().trim(); 
    	  var qushu = $("#wactuate option:selected").text().trim();
     $.ajax({
           url : '<%=basePath%>cars/getChangjiaByDeparture',
            data:{
             	mudidiobject: mudidi,
             	shifaobject: shifa,
             	chexingobject: chexing,
             	qushuobject: qushu,
             },
            type : 'post',
            dataType : 'json',
            async : false,          
            success : function(data) {
                console.log(data);  
                  if(data!=null){
                      //   $("#wfactory").prepend("<option value='0'>请选择</option>"); 
                        $.each(data,function(i,item){
                              $.each(item,function(j,val){
                                  $("#wfactory").append("<option value="+val.cexpense+">"+val.cexpense+"</option>");
                                    $("#wpilot").append("<option value="+val.cbrand+">"+val.cbrand+"</option>");
                              })
                          });  
                   }                                                   
            }
     })
}

function fifthQuery(){
    $("#wpilot").empty();
     	 var mudidi = $("#wbourn option:selected").text().trim();   
   	 	 var shifa = $("#wcommence option:selected").text().trim();
    	 var chexing = $("#wvin option:selected").text().trim(); 
    	 var qushu = $("#wactuate option:selected").text().trim();
    	 var changjiajiesuan = $("#wfactory option:selected").text().trim();
     $.ajax({
           url : '<%=basePath%>cars/getJiashiJiesuanByDeparture',
            data:{
             	mudidiobject: mudidi,
             	shifaobject: shifa,
             	chexingobject: chexing,
             	qushuobject: qushu,
             	changjiajiesuannobject: changjiajiesuan,
             },
            type : 'post',
            dataType : 'json',
            async : false,          
            success : function(data) {
                console.log(data);  
                  if(data!=null){
                        /*  $("#wpilot").prepend("<option value='0'>请选择</option>");  */
                        $.each(data,function(i,item){
                              $.each(item,function(j,val){
                                  $("#wpilot").append("<option value="+val.cexpense+">"+val.cexpense+"</option>");
                              })
                          });  
                   }                                                   
            }
     })
}
</script>
	
	
	
	
	
	<script type="text/javascript">
		$('.timepick').fdatepicker({
			format: 'yyyy-mm-dd hh',
			pickTime: 1,
		});
	</script>
	
	<script type="text/javascript">

		!function(){
		
			laydate.skin('dahong');//切换皮肤，请查看skins下面皮肤库
		
			laydate({elem: '#demo'});
			laydate({elem: '#demo1'});
			laydate({elem: '#demo2'});
			laydate({elem: '#demo3'});//绑定元素
			//绑定元素
		
		}();
		
		
		
		//日期范围限制
		
		var start = {
		
		    elem: '#start',
		
		    format: 'YYYY-MM-DD',
		
		    min: laydate.now(), //设定最小日期为当前日期
		
		    max: '2099-06-16', //最大日期
		
		    istime: true,
		
		    istoday: false,
		
		    choose: function(datas){
		
		         end.min = datas; //开始日选好后，重置结束日的最小日期
		
		         end.start = datas //将结束日的初始值设定为开始日
		
		    }
		
		};
		
		
		
		var end = {
		
		    elem: '#end',
		
		    format: 'YYYY-MM-DD',
		
		    min: laydate.now(),
		
		    max: '2099-06-16',
		
		    istime: true,
		
		    istoday: false,
		
		    choose: function(datas){
		
		        start.max = datas; //结束日选好后，充值开始日的最大日期
		
		    }
		
		};
		
		laydate(start);
		
		laydate(end);
		
		
	</script>
	<script type="text/javascript">
		function yuntest(){
			var wcommence = document.getElementById("wcommence").value;
			if(wcommence==null||wcommence==""||wcommence==undefined||wcommence=="--请选择--"){
				alert("请选择始发地");
				return false;
			}
	    	var wbourn = document.getElementById("wbourn").value;
	    	if(wbourn==null||wbourn==""||wbourn==undefined||wbourn=="--请选择--"||wbourn==0){
				alert("请选择目的地");
				return false;
			}
	    	var wvehicle = document.getElementById("wvehicle").value;
	    	if(wvehicle==null||wvehicle==""||wvehicle==undefined){
				alert("请输入车架号");
				return false;
			}
	    	var wvin = document.getElementById("wvin").value;
			if(wvin==null||wvin==""||wvin==undefined||wvin==0){
				alert("请选择车型");
				return false;
			}
	    	var wactuate = document.getElementById("wactuate").value;
	    	if(wactuate==null||wactuate==""||wactuate==undefined||wactuate==0){
				alert("请选择驱数");
				return false;
			}
			
	    	var wdeparturetime = document.getElementById("wdeparturetime").value;
	    	if(wdeparturetime==null||wdeparturetime==""||wdeparturetime==undefined){
				alert("请选择发车时间");
				return false;
			}
	    	var westimatedtime = document.getElementById("westimatedtime").value;
	    	if(westimatedtime==null||westimatedtime==""||westimatedtime==undefined){
				alert("请选择预计到达时间");
				return false;
			}
	    	var wneartime = document.getElementById("wneartime").value;
	    	if(wneartime==null||wneartime==""||wneartime==undefined){
				alert("请选择临牌到达时间");
				return false;
			}
	    	var winsurancetime = document.getElementById("winsurancetime").value;
	    	if(winsurancetime==null||winsurancetime==""||winsurancetime==undefined){
				alert("请选择保险到达时间");
				return false;
			}
	    	var wtransport = document.getElementById("wtransport").value;
	    	if(wtransport==null||wtransport==""||wtransport==undefined||wtransport=="--请选择--"){
				alert("请选择运送驾驶员");
				return false;
			}
	    	var wcommercial = document.getElementById("wcommercial").value;
	    	if(wcommercial==null||wcommercial==""||wcommercial==undefined){
				alert("请输入商业险金额（元）");
				return false;
			}
			if (!/^\d+\.?\d{0,2}$/.test(wcommercial)) {
			    	alert("请输入商业险正确金额!");
			    	return false;
			    }
	    	var wcoerce = document.getElementById("wcoerce").value;
	    	if(wcoerce==null||wcoerce==""||wcoerce==undefined){
				alert("请输入强险金额（元）");
				return false;
			}
			if (!/^\d+\.?\d{0,2}$/.test(wcoerce)) {
			    	alert("请输入强险正确金额!");
			    	return false;
			    }
	    	var wamount = document.getElementById("wamount").value;
			if(wamount==null||wamount==""||wamount==undefined){
				alert("请输入临牌金额（元）");
				return false;
			}
			if (!/^\d+\.?\d{0,2}$/.test(wamount)) {
			    	alert("请输入临牌正确金额!");
			    	return false;
			    }
	    	
		}
	</script>
	
	<script type="text/javascript"> 
		   window.onload=function(){ 
				var action ='<%=request.getAttribute("result")%>';
				if(action.length!==4)
				{
						alert(action);
				}
			} 
		</script>
</html>
